package thread;

public class ThreadDemo15 {
    private static long result = 0;
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(() -> {
            for (long i = 0; i <= 50_0000_0000l; i++) {
                result += i;
            }
        });
        Thread t2 = new Thread(() -> {
            for (long i = 50_0000_0001l; i <= 100_0000_0000l; i++) {
                result += i;
            }
        });
        t.start();
        t2.start();
        long beg = System.currentTimeMillis();

        t.join();
        t2.join();
        long end = System.currentTimeMillis();
        System.out.println("result = " + result);
        System.out.println("time = " + (end - beg) + " ms");
    }
}
